import { ref } from 'vue'
import { defineStore } from 'pinia'
import type { UserInfo } from '@/types/user'
import type { RouteRecordRaw } from 'vue-router';


export const useUserStore = defineStore('user', () => {
    // 用户信息
    const userInfo = ref<UserInfo>()
    // 用户路由
    const userRouter = ref<RouteRecordRaw[]>()

    const setUserInfo = (info: UserInfo) => {
        userInfo.value = info
    }

    const clearUserInfo = () => {
        userInfo.value = undefined
    }

    const setUserRouter = (routes: RouteRecordRaw[]) => {
        userRouter.value = routes
    }

    return {
        userInfo,
        userRouter,
        setUserInfo,
        clearUserInfo,
        setUserRouter
    }
})
